feat(cli): resume without sessionId opens tui session picker#139
Merged
Conversation
Make `resume` work without `<sessionId>` by opening the TUI directly on the session manager screen, using a `LaunchOptions` object to pass both `sessionId` and `initialScreen`.
Changes:
1. `src/tui.tsx`
- Change `renderApp(sessionId?: string)` → `renderApp(options: LaunchOptions = {})`.
- Pass `options.sessionId` and `options.initialScreen` through to `<App>`.
- `screen.setClearHandler` rerender: pass `{ sessionId: nextSessionId ?? options.sessionId }` (drop `initialScreen` on rerender — resets to chat).
2. `src/components/App/App.tsx`
- Change `Props` from `{ sessionId?: string }` → `{ sessionId?: string; initialScreen?: Screen }`.
- Pass `initialScreen` to `useScreenRouter`.
3. `src/components/App/hooks/useScreenRouter.ts`
- Accept `initialScreen?: Screen` param.
- Change `useState<Screen>(SCREEN.CHAT)` → `useState<Screen>(initialScreen ?? SCREEN.CHAT)`.
4. `src/cli.ts`
- Import `{ SCREEN } from './constants'` and `type { Screen } from './types'`.
- Define `interface LaunchOptions { sessionId?: string; initialScreen?: Screen }`.
- Change `'resume <sessionId>'` → `'resume [sessionId]'` (optional arg).
- Update action: if `sessionId` provided, load + validate as today; if absent, `launchTui({ initialScreen: SCREEN.SESSION_MANAGER })`.
- Change `launchTui(sessionId?: string)` → `launchTui(options: LaunchOptions = {})`, pass `options` to `renderApp`.
5. Tests
**`src/cli.test.ts`**
- Update `ResumeAction` type: `(sessionId?: string) => Promise<void>`.
- Update existing `renderApp` call assertions: `renderApp('session-1')` → `renderApp({ sessionId: 'session-1' })`.
- Update no-args TUI test: `renderApp(undefined)` → `renderApp({})`.
- Add: `resume` with no `sessionId` → `renderApp({ initialScreen: SCREEN.SESSION_MANAGER })`, no `loadSession` call.
**`src/tui.test.tsx`**
- Update `renderApp()` call → `renderApp({})` (or keep no-arg if default param is used).
- Verify `App` receives correct props for both `sessionId` and `initialScreen` paths.
**`src/components/App/hooks/useScreenRouter.test.ts`** _(if it exists)_
- Add a test for `initialScreen: SCREEN.SESSION_MANAGER` starting on that screen.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the motivation for this pull request?
Feature: allow
resumeto be called without a<sessionId>argument. Previously the argument was required; users had to know the session ID to resume. This makes the command more discoverable and convenient.plan.md
What is the current behavior?
code-ollama resumerequires a<sessionId>argument — omitting it results in a CLI usage error.What is the new behavior?
code-ollama resume <sessionId>— unchanged: loads and resumes the specific session.code-ollama resume— opens the TUI directly on the session manager screen, where the user can pick a session to open (or start a new one).Internally,
renderAppnow accepts aLaunchOptionsobject ({ sessionId?, initialScreen? }) instead of a plainsessionIdstring.useScreenRouteraccepts aninitialScreenoption to seed its initialuseState.Checklist: